<template>
  <div class="test-container">
    <div class="test-header">
      <h2>签名弹框测试</h2>
    </div>
    
    <div class="test-content">
      <button class="test-btn" @click="openSignatureModal">打开签名弹框</button>
      
      <div v-if="signatureResult" class="result-area">
        <h3>签名结果：</h3>
        <p>时间戳: {{ signatureResult.timestamp }}</p>
        <div class="signature-preview">
          <img :src="signatureResult.signatureData" alt="签名预览" />
        </div>
      </div>
    </div>
    
    <!-- 签名弹框 -->
    <SignatureModal 
      :visible="showSignatureModal"
      @close="closeSignatureModal"
      @submit="handleSignatureSubmit"
    />
  </div>
</template>

<script>
import SignatureModal from '@/components/signature-modal.vue'

export default {
  name: 'SignatureTest',
  components: {
    SignatureModal
  },
  data() {
    return {
      showSignatureModal: false,
      signatureResult: null
    }
  },
  methods: {
    openSignatureModal() {
      this.showSignatureModal = true;
    },
    closeSignatureModal() {
      this.showSignatureModal = false;
    },
    handleSignatureSubmit(signatureInfo) {
      this.signatureResult = signatureInfo;
      console.log('签名提交成功:', signatureInfo);
      
      uni.showToast({
        title: '签名提交成功',
        icon: 'success'
      });
    }
  }
}
</script>

<style scoped lang="scss">
.test-container {
  padding: 40rpx;
  background: #f5f5f5;
  min-height: 100vh;
}

.test-header {
  text-align: center;
  margin-bottom: 60rpx;
  
  h2 {
    font-size: 48rpx;
    color: #333;
  }
}

.test-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.test-btn {
  background: #409eff;
  color: #fff;
  border: none;
  border-radius: 12rpx;
  padding: 30rpx 60rpx;
  font-size: 32rpx;
  margin-bottom: 60rpx;
  cursor: pointer;
}

.result-area {
  background: #fff;
  border-radius: 16rpx;
  padding: 40rpx;
  width: 100%;
  max-width: 600rpx;
  
  h3 {
    font-size: 36rpx;
    color: #333;
    margin-bottom: 20rpx;
  }
  
  p {
    font-size: 28rpx;
    color: #666;
    margin-bottom: 30rpx;
  }
}

.signature-preview {
  border: 2rpx solid #ddd;
  border-radius: 12rpx;
  padding: 20rpx;
  text-align: center;
  
  img {
    max-width: 100%;
    max-height: 300rpx;
    border-radius: 8rpx;
  }
}
</style> 